PyTest BDD Energyworx
The PyTest BDD Energyworx plugin is a collection of PyTest fixtures that help in testing the Energyworx platform in a Behavioural Driven Development (BDD) way.
For more information about PyTest itself or what fixtures are, please consult the PyTest documentation.
The following sections describe how to install the plugin. Once installed, follow Getting Started with pytest-bdd-ewx to write and run your first scenario.
Prerequisites
- Python 3.13
- gcloud CLI
- Access to Artifact Registry project
ewx-global
Authenticate with gcloud
gcloud auth application-default login
Installation with pip
pytest-bdd-ewx is normally installed alongside ewx-cli so you can both manage configurations and run BDD scenarios from the same project.
- macOS / Linux
- Windows (PowerShell)
mkdir my_ewx_tests
cd my_ewx_tests
python3.13 -m venv .venv
source .venv/bin/activate
pip install --upgrade pip
pip install keyring keyrings.google-artifactregistry-auth
pip install \
--index-url https://europe-west1-python.pkg.dev/ewx-global/python-shared/simple/ \
--extra-index-url https://pypi.org/simple/ \
ewx-cli==26.2.0 pytest-bdd-ewx==26.2.0
mkdir my_ewx_tests
cd my_ewx_tests
py -3.13 -m venv .venv
.venv\Scripts\Activate.ps1
pip install --upgrade pip
pip install keyring keyrings.google-artifactregistry-auth
pip install `
--index-url https://europe-west1-python.pkg.dev/ewx-global/python-shared/simple/ `
--extra-index-url https://pypi.org/simple/ `
ewx-cli==26.2.0 pytest-bdd-ewx==26.2.0
If Activate.ps1 is blocked by execution policy, run Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned once and reopen PowerShell.
Pin both packages to the version that matches the platform release you target — for platform release YY.MM the package version is YY.M.0. See Versioning for details.
Installation with Poetry
Use this pyproject.toml as a starting point:
[project]
name = "my-ewx-tests"
version = "0.1.0"
description = "Automated BDD test project for Energyworx."
requires-python = ">=3.13,<3.14"
dependencies = [
"pytest>=8.4.2,<9.0.0",
"pytest-bdd>=8.1.0,<9.0.0",
"ewx-cli==26.2.0",
"pytest-bdd-ewx==26.2.0",
]
[tool.poetry]
package-mode = false
[tool.poetry.dependencies]
ewx-cli = { version = "26.2.0", source = "ewx-global" }
pytest-bdd-ewx = { version = "26.2.0", source = "ewx-global" }
[[tool.poetry.source]]
name = "ewx-global"
url = "https://europe-west1-python.pkg.dev/ewx-global/python-shared/simple/"
priority = "explicit"
[build-system]
requires = ["poetry-core>=2.0.0,<3.0.0"]
build-backend = "poetry.core.masonry.api"
Then run:
- macOS / Linux
- Windows (PowerShell)
gcloud auth application-default login
export POETRY_HTTP_BASIC_EWX_GLOBAL_USERNAME=oauth2accesstoken
export POETRY_HTTP_BASIC_EWX_GLOBAL_PASSWORD="$(gcloud auth print-access-token)"
poetry env use python3.13
poetry install
gcloud auth application-default login
$env:POETRY_HTTP_BASIC_EWX_GLOBAL_USERNAME = "oauth2accesstoken"
$env:POETRY_HTTP_BASIC_EWX_GLOBAL_PASSWORD = (gcloud auth print-access-token)
poetry env use (py -3.13 -c "import sys; print(sys.executable)")
poetry install
Note: the access token expires. Re-run the POETRY_HTTP_BASIC_EWX_GLOBAL_PASSWORD assignment when needed.
Next steps
- Getting Started with pytest-bdd-ewx — set up a test project and run your first scenario
- Using the plugin — writing scenarios, test data, configuration management
- Plugin features — what the plugin provides out of the box
- Available Gherkin Steps — reference of all built-in step definitions
- ewx-cli — uploading and downloading configurations